<template>
    <div style="margin: 20px;" id="app">
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="书名">
                <el-input v-model="form.bookName"></el-input>
            </el-form-item>
            <el-form-item label="价格">
                <el-input v-model="form.price"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit()">登录</el-button>
                <el-button>注册</el-button>
            </el-form-item>
        </el-form></div>
</template>

<script>
    export default {
        name: "Login",
        data() {
            return {
                form: {
                    bookName: '',
                    price:null
                }
            }
        },
        methods: {
            onSubmit() {
                this.$wdz.post("http://localhost:8001/list/admin",this.form).then(resp=>{
                if (resp.data.code===200){
                    // 获取服务器响应的toke的值，保存到localstorage
                    localStorage.setItem("token",resp.data.data)
                    // 跳转路由 不能使用hre
                    this.$router.push("/AboutView.vue")
                    this.$message.success("跳转成功！")


                }else if (resp.data.code===500){
                    this.$message.error("跳转失败！")
                    this.$router.push("/Login.vue")
                }
                })
            }
        }
    }
</script>

<style scoped>

</style>